const counter = createCounter(5);
function createCounter(initNum) {
    return function add(num) {
         initNum=num?num+1:initNum+1
       return initNum
    }
}
console.log(counter()); // 6
console.log(counter()); // 7
console.log(counter()); // 8
console.log(counter(10)); // 11
console.log(counter()); // 12